package com.kehao.newcoder;

public class NC7Solution {

    public int maxProfit (int[] prices) {
        int result =0;
        int minPrice = prices[0];
        for (int i = 1; i < prices.length; i++) {
            int profit = prices[i] - minPrice;
            if(profit>result){
                result = profit;
            }
            if(minPrice>prices[i]){
                minPrice = prices[i];
            }
        }
        return result;
    }
}
